home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / raid / devRaidUtil.h < prev    next >
C/C++ Source or Header  |  1990-10-12  |  5KB  |  104 lines

  1. /*
  2.  * devRaidUtil.h --
  3.  *
  4.  *    Miscellaneous mapping macros.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/kernel/raid/RCS/devRaidUtil.h,v 1.8 90/10/12 14:01:26 eklee Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _DEVRAIDUTIL
  19. #define _DEVRAIDUTIL
  20.  
  21. #include <sprite.h>
  22. #include "devBlockDevice.h"
  23. #include "devRaid.h"
  24.  
  25. /*
  26.  * Maps a RAID sector to stripe ID and visa versa.
  27.  */
  28. #define SectorToStripeID(raidPtr, sector)    \
  29.     ((int)((sector) / (raidPtr)->sectorsPerStripeUnit) / (raidPtr)->numDataCol)
  30.  
  31. #define StripeIDToSector(raidPtr, stripeID)    \
  32.     ((stripeID) * (raidPtr)->sectorsPerStripeUnit * (raidPtr)->numDataCol)
  33.  
  34. /*
  35.  * Maps RAID sector to stripe unit ID.
  36.  */
  37. #define SectorToStripeUnitID(raidPtr, sector)    \
  38.     ((sector) / (raidPtr)->sectorsPerStripeUnit)
  39.  
  40. /*
  41.  * Maps RAID/disk byte addresses to RAID/disk sector addresses and visa versa.
  42.  */
  43. #define ByteToSector(raidPtr, byteAddr)        \
  44.     ((byteAddr) >> (raidPtr)->logBytesPerSector)
  45.  
  46. #define SectorToByte(raidPtr, sector)        \
  47.     ((sector) << (raidPtr)->logBytesPerSector)
  48.  
  49. /*
  50.  * Determine first/Nth sector of stripe.
  51.  */
  52. #define FirstSectorOfStripe(raidPtr, sector)    \
  53.     (((sector)/(raidPtr)->dataSectorsPerStripe)*(raidPtr)->dataSectorsPerStripe)
  54.  
  55. #define NthSectorOfStripe(raidPtr, sector)    \
  56. ((((sector)/(raidPtr)->dataSectorsPerStripe)+1)*(raidPtr)->dataSectorsPerStripe)
  57.  
  58. /*
  59.  * Determine first/Nth sector of stripe unit.
  60.  */
  61. #define FirstSectorOfStripeUnit(raidPtr, sector)    \
  62.     (((sector)/(raidPtr)->sectorsPerStripeUnit)*(raidPtr)->sectorsPerStripeUnit)
  63.  
  64. #define NthSectorOfStripeUnit(raidPtr, sector)    \
  65. ((((sector)/(raidPtr)->sectorsPerStripeUnit)+1)*(raidPtr)->sectorsPerStripeUnit)
  66.  
  67. /*
  68.  * Determine byte offset within stripe unit.
  69.  */
  70. #define StripeUnitOffset(raidPtr, byteAddr)    \
  71.     ((byteAddr) % (raidPtr)->bytesPerStripeUnit)
  72.  
  73. #define XorRaidRequests(reqControlPtr, raidPtr, destBuf)        \
  74.     (Raid_XorRangeRequests(reqControlPtr, raidPtr, destBuf,        \
  75.         0, raidPtr->bytesPerStripeUnit))
  76.  
  77. #define AddRaidDataRequests(reqControlPtr, raidPtr, operation, firstSector, nthSector, buffer, ctrlData)            \
  78.     (Raid_AddDataRangeRequests(reqControlPtr, raidPtr, operation,     \
  79.         firstSector, nthSector, buffer, ctrlData,            \
  80.         0, raidPtr->bytesPerStripeUnit))
  81.  
  82. #define AddRaidParityRequest(reqControlPtr, raidPtr, operation, firstSector, buffer, ctrlData)            \
  83.     (Raid_AddParityRangeRequest(reqControlPtr, raidPtr, operation,     \
  84.         firstSector, buffer, ctrlData,            \
  85.         0, raidPtr->bytesPerStripeUnit))
  86.  
  87. extern DevBlockDeviceRequest *Raid_MakeBlockDeviceRequest _ARGS_((Raid *raidPtr,
  88.  int operation, unsigned diskSector, int numSectorsToTransfer, Address buffer, void (*doneProc)(), ClientData clientData, int ctrlData));
  89. extern void Raid_FreeBlockDeviceRequest _ARGS_((DevBlockDeviceRequest *requestPtr));
  90. extern RaidIOControl *Raid_MakeIOControl _ARGS_((void (*doneProc)(), ClientData clientData));
  91. extern void Raid_FreeIOControl _ARGS_((RaidIOControl *IOControlPtr));
  92. extern RaidRequestControl *Raid_MakeRequestControl _ARGS_((Raid *raidPtr));
  93. extern void Raid_FreeRequestControl _ARGS_((RaidRequestControl *reqControlPtr));
  94. extern RaidStripeIOControl *Raid_MakeStripeIOControl _ARGS_((Raid *raidPtr, int operation, unsigned firstSector, unsigned nthSector, Address buffer, void (*doneProc)(), ClientData clientData, int ctrlData));
  95. extern void Raid_FreeStripeIOControl _ARGS_((RaidStripeIOControl *stripeIOControlPtr));
  96. extern RaidReconstructionControl *Raid_MakeReconstructionControl _ARGS_((Raid *raidPtr, int col, int row, RaidDisk *diskPtr, void (*doneProc)(), ClientData clientData, int ctrlData));
  97. extern void Raid_FreeReconstructionControl _ARGS_((RaidReconstructionControl *reconstructionControlPtr));
  98. extern void Raid_RangeRestrict _ARGS_((int start, int len, int rangeOffset, int rangeLen, int fieldLen, int *newStart, int *newLen));
  99. extern void Raid_XorRangeRequests _ARGS_((RaidRequestControl *reqControlPtr, Raid *raidPtr, char *destBuf, int rangeOffset, int rangeLen));
  100. extern void Raid_AddParityRangeRequest _ARGS_((RaidRequestControl *reqControlPtr, Raid *raidPtr, int operation, unsigned sector, Address buffer, int ctrlData, int rangeOffset, int rangeLen));
  101. extern void Raid_AddDataRangeRequests _ARGS_((RaidRequestControl *reqControlPtr, Raid *raidPtr, int operation, unsigned firstSector, unsigned nthSector, Address buffer, int ctrlData, int rangeOffset, int rangeLen));
  102.  
  103. #endif /* _DEVRAIDUTIL */
  104.